package com.shouhuobao.take.parcel;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.iseastar.guojiang.BaseActivity;
import com.shouhuobao.station.R;
import com.shouhuobao.take.utils.AppTab;

import droid.frame.view.ViewPagerExt;

/**
 * 包裹列表已到店，已取走，已超期fragment的宿主activity <br>
 * Created by joker on 2017/5/25.
 */
public class ParcelActivity extends BaseActivity {

	/**
	 * 进入页面默认选择的item
	 */
	private int selectItem;
	private BaseParcelFragment mFragment1, mFragment2, mFragment3;

	@Override
	@SuppressLint("ResourceAsColor")
	protected void onCreate(Bundle savedInstanceState) {
		selectItem = getIntent().getIntExtra("item", 0);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void findViewById() {
		setContentView(R.layout.take_parcel_main);
		super.findViewById();
		getAppTitle().setCommonTitle("包裹列表", null);

		TextView[] mTags = new TextView[3];
		mTags[0] = (TextView) findViewById(R.id.parcel_tab1);
		mTags[1] = (TextView) findViewById(R.id.parcel_tab2);
		mTags[2] = (TextView) findViewById(R.id.parcel_tab3);

		initFragment();

		ViewPagerExt mViewPager = (ViewPagerExt) findViewById(R.id.viewpager);
		ImageView mImgLine = (ImageView) findViewById(R.id.my_parcel_line_img);
		mViewPager.setFragmentItems(getSupportFragmentManager(), mFragment1, mFragment2, mFragment3);
		mViewPager.setSupportScroll(true);
		AppTab appTab = new AppTab(getContext(), 0);
		appTab.initPosition(mViewPager, mImgLine, mTags);

		mViewPager.setCurrentItem(selectItem, true);
		mViewPager.setOffscreenPageLimit(3);
	}

	private void initFragment() {
		mFragment1 = new Parcel1Fragment();
		Bundle bundle1 = new Bundle();
		bundle1.putInt("type", 0);
		mFragment1.setArguments(bundle1);
		//
		Bundle bundle2 = new Bundle();
		bundle2.putInt("type", 1);
		mFragment2 = new Parcel2Fragment();
		mFragment2.setArguments(bundle2);
		//
		Bundle bundle3 = new Bundle();
		bundle3.putInt("type", 2);
		mFragment3 = new Parcel3Fragment();
		mFragment3.setArguments(bundle3);
	}

}
